<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="form-horizontal m-t" id="signupForm">
                        <!--						<input id="id" name="id" th:value="${refundMoneyLog.id}"  type="hidden">-->
                        <div class="form-group">
                            <label class="col-sm-3 control-label">对公返费金额：</label>
                            <div class="col-sm-8">
                                <input id="returnMoneySchool" name="returnMoneySchool"
                                       placeholder="请输入对公返费金额"
                                       class="form-control" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">对私返费金额：</label>
                            <div class="col-sm-8">
                                <input id="returnMoneyPersonal" name="returnMoneyPersonal"
                                       placeholder="请输入对私返费金额"
                                       class="form-control" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <input id="remark" name="remark"
                                       placeholder="请输入备注"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">凭证文件：</label>
                            <div class="col-sm-8" style="display: flex;">
                                <input type="text" name="file" id="fileURL" placeholder="文件路径" class="form-control">
                                <button type="button" class="layui-btn demo-class-accept" lay-options="{accept: 'file'}">
                                    <i class="layui-icon layui-icon-upload"></i>
                                    上传文件
                                </button>
                            </div>
                        </div>

                        <!--                            <div class="col-sm-8">-->
                        <!--                                <input id="file" name="file"  class="form-control"-->
                        <!--                                       type="text">-->
                        <!--                            </div>-->

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary" onclick="edit()">提交</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script src="//s.xlongwei.com/res/js/My97DatePicker/WdatePicker.js"></script>
<!--<script type="text/javascript" src="/js/webJs/jzweb/refundMoneyLog/edit.js">-->
<script>
    var dataList = JSON.parse(sessionStorage.getItem('ref_money'))
    $(function () {
        $('#returnMoneyPersonal').val(dataList.returnMoneyPersonal)
        $('#returnMoneySchool').val(dataList.returnMoneySchool)
    });
    // /common/sysFile/upload

    layui.use(function(){
        var upload = layui.upload;
        var layer = layui.layer
        // 渲染
        upload.render({
            elem: '.demo-class-accept',
            accept: 'file',
            url: '/common/sysFile/upload', // 此处配置你自己的上传接口即可
            done: function(res){
                $('#fileURL').val(res.data)
                layer.msg('上传成功');
                console.log(res)
            }
        });
    });

    function edit() {
        if(!$('#returnMoneySchool').val()){
            layer.msg('请输入对公返费金额');
            return false
        }
        if(!$('#returnMoneyPersonal').val()){
            layer.msg('请输入对私返费金额');
            return false
        }
        if(!$('#fileURL').val()){
            layer.msg('请上传凭证文件');
            return false
        }
        $.ajax({
            url: "/jzweb/examinationCost/updateRefundMoney  ",
            type: "POST",
            data: {
                'id': dataList.id,
                'moneyDs': $('#returnMoneyPersonal').val(),
                'moneyDg' :$('#returnMoneySchool').val(),
                'remark': $('#remark').val(),
                'file': $('#fileURL').val(),
            }, success: function (r) {
                if (r.code === '0') {
                    parent.reLoad();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);
                    layer.msg(r.msg);
                } else {
                    layer.msg(r.msg);
                }
            }

        });
    }


</script>
</body>
</html>
